package com.pai4j.aigc.context.schedule;

import com.pai4j.aigc.context.service.ChatContextService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import jakarta.annotation.Resource;

@Slf4j
@Component
public class ContextScheduler {

    @Resource
    private ChatContextService chatContextService;

    // 每小时触发一次全量检查（可在配置中覆盖cron）
    @Scheduled(cron = "${aigc.context.scheduler.summarize.cron:0 0 * * * ?}")
    public void summarizeAll() {
        try {
            chatContextService.summarizeAllSessions();
        } catch (Exception e) {
            log.warn("summarizeAllSessions error", e);
        }
    }
}
